#include <iostream>

using std::cout;
using std::endl;

class Point
{
public:
    Point(int ix = 0, int iy = 0)
    : _ix(ix)
    , _iy(iy)
    {
        cout << "Point(int = 0, int  = 0 )" << endl;
    }

    int getY() const
    {
        return _iy;
    }

    ~Point()
    {
        cout << "~Point()" << endl;
    }

protected:
    int _ix;
private://封装性
    int _iy;
};

class Point3D
: private Point
{
public:
    Point3D(int ix = 0, int iy = 0, int iz = 0)
    : Point(ix, iy)//为了完成从基类吸收过来的数据
    , _iz(iz)//成员的初始化，可以借助基类构造函数
    {
        cout << "Point3D(int = 0, int = 0, int = 0 )" << endl;
    }

    void print() const
    {
        cout << "( " << _ix //private
             /* << ", " << _iy //error */
             << ", " << getY()//ok,private,吸收与访问是两码事
             << ", " << _iz//private
             << ")" << endl;
    }

    ~Point3D()
    {
        cout << "~Point3D()" << endl;
    }
private:
    int _iz;
};

class Point4D
: private Point3D
{
public:
    void show() const
    {
        /* cout << "( " << _ix //error */
             /* << ", " << _iy //error */
             /* << ", " << getY()//error */
             /* << ", " << _iz//error */
             /* << ", " << _im//ok */
             /* << ")" << endl; */
    }

private:
    int _im;
};
void test()
{
    cout << "sizeof(Point) = " << sizeof(Point) << endl;
    cout << "sizeof(Point3D) = " << sizeof(Point3D) << endl;
    Point3D pt3d(1, 2, 3);
    /* pt3d._ix;//error */
    /* pt3d._iy;//error */
    /* pt3d.getY();//error,在基类中是public修饰，并且是public继承 */
}

int main(int argc, char **argv)
{
    test();
    return 0;
}

